/**
* Created by Administrator on 2025/5/15.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "AIE2ENet/AIE2ENet.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "MyDeviceWriter/MyDeviceWriter.h"
#include "MyDeviceReader_1/MyDeviceReader_1.h"
#include "AIE2ETrainController/AIE2ETrainController.h"
#include "EthernetReader.h"
#include "EthernetWriter.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=14;
    config->servicePort=55261;
    config->ip="192.168.1.115";
    config->userVersion="1.0";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(AIE2ENet,MyDeviceReader,MyDeviceReader_1,MyDeviceWriter,AIE2ETrainController);
    auto aiE2ENet = new AIE2ENet();
    auto aiE2ETrainController = new AIE2ETrainController();

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(aiE2ENet,0,1024);
    radarlabReader->addTaskModule(aiE2ETrainController,0,1024);

    auto radarlabReader_1 = new MyDeviceReader_1();
    radarlabReader_1->addTaskModule(aiE2ENet,1,1024);

    auto radarlabReader_2 = new EthernetReader(TCP,6674);
    radarlabReader_2->addTaskModule(aiE2ETrainController,1,1024);

    auto radarlabReader_3 = new EthernetReader(TCP,6678);
    radarlabReader_3->addTaskModule(aiE2ETrainController,2,1024);

    aiE2ETrainController->setLaunchPolicy(LaunchMode_OR,LaunchCondition());

    auto radarlabWriter = new MyDeviceWriter();
    aiE2ENet->addDeviceWriter(0,radarlabWriter,1024);

    auto radarlabWriter_1 = new MyDeviceWriter();
    aiE2ETrainController->addDeviceWriter(0,radarlabWriter_1,1024);

    auto radarlabWriter_2 = new EthernetWriter(TCP,"192.168.1.115",6677,true);
    aiE2ENet->addDeviceWriter(1,radarlabWriter_2,1024);
    REGISTER_INSTANCES(aiE2ENet,radarlabReader,radarlabReader_1,radarlabWriter,radarlabWriter_2,aiE2ETrainController,radarlabReader_2,radarlabReader_3,radarlabWriter_1);
}
